package pkg;

import java.util.ArrayList;
import java.util.Scanner;

public class Ice_Cream extends Product
{
	public static final double BASE_PRICE = 3.75;
	
	public static final double SMALL_VOLUME = 2.5;
	public static final double MEDIUM_VOLUME = 3.5;
	public static final double LARGE_VOLUME = 5.0;
	
	public static final double SMALL_MODIFIER = 1.0;
	public static final double MEDIUM_MODIFIER = 1.15;
	public static final double LARGE_MODIFIER = 1.25;
	
	ArrayList<Size> icecream_sizes;
	Style serving_style;
	Container serving_container;
	Size serving_size;
	Flavor serving_flavor;
	String icecream_label;
	
	public Ice_Cream(Flavor c_flavor, Style c_style, Container c_container, Size c_size)
	{
		serving_flavor = c_flavor;
		serving_style = c_style;
		serving_container = c_container;
		serving_size = c_size;
		icecream_label = getName();
	}
	public Ice_Cream()
	{
		icecream_label = "SubMenu prompt stub object";
		icecream_sizes = new ArrayList<Size>();
		icecream_sizes.add(new Size_Small(SMALL_VOLUME, SMALL_MODIFIER));
		icecream_sizes.add(new Size_Medium(MEDIUM_VOLUME, MEDIUM_MODIFIER));
		icecream_sizes.add(new Size_Large(LARGE_VOLUME, LARGE_MODIFIER));
	}
	
	public String getGenericLabel()
	{
		return "Ice Cream";
	}
	public String getName()
	{
		return serving_size.getLabel() + " " + serving_flavor.getLabel() + " " + serving_style.getLabel() + 
			   " Ice Cream in a " + serving_container.getLabel();
	}
	public double getPrice()
	{
		return BASE_PRICE * serving_size.getPriceModifier();
	}
	
	public String getDirections()
	{
		return "Under Construction";
	}
	
	public static ArrayList<Flavor> getFlavors()
	{
		ArrayList<Flavor> retList = new ArrayList<Flavor>();
		retList.add(new IceCream_Chocolate());
		retList.add(new IceCream_Mint());
		retList.add(new IceCream_RockyRoad());
		retList.add(new IceCream_Strawberry());
		retList.add(new IceCream_Vanilla());
		
		return retList;
	}
	
	public static ArrayList<Style> getStyles()
	{
		ArrayList<Style> retList = new ArrayList<Style>();
		retList.add(new Scoop());
		retList.add(new Soft_Serve());
		
		return retList;
	}
	
	public static ArrayList<Container> getContainers()
	{
		ArrayList<Container> retList = new ArrayList<Container>();
		retList.add(new Bowl());
		retList.add(new Cake_Cone());
		retList.add(new Sugar_Cone());
		retList.add(new Waffle_Cone());
		
		return retList;
	}
	public Ice_Cream submenuPrompt()
	{
		Scanner in = new Scanner(System.in);
		int selection;
		ArrayList<Flavor> flavorList = Ice_Cream.getFlavors();
		ArrayList<Style> styleList = Ice_Cream.getStyles();
		ArrayList<Container> containerList = Ice_Cream.getContainers();
		ArrayList<Size> sizeList = icecream_sizes;
		Flavor selectedFlavor;
		Style selectedStyle;
		Size selectedSize;
		Container selectedContainer;
		
		//Flavor
		System.out.println("Please select the flavor of ice cream the customer ordered:");

		for(int i = 1; i < flavorList.size()+1; i++)
		{
			System.out.println("\t"+i+" - " + flavorList.get(i - 1).getLabel());
		}
		System.out.print("\nMake a selection:");
		selection = in.nextInt();

		while (selection > flavorList.size() || selection < 1)
		{
			System.out.println("\nInvalid selection, please select again.");
			selection = in.nextInt();
		}
		selectedFlavor = flavorList.get(selection - 1);
		selection = -1;
		
		//Style
		System.out.println("Please select the style of ice cream the customer ordered:");

		for(int i = 1; i < styleList.size()+1; i++)
		{
			System.out.println("\t"+i+" - " + styleList.get(i - 1).getLabel());
		}
		System.out.print("\nMake a selection:");
		selection = in.nextInt();

		while (selection > styleList.size() || selection < 1)
		{
			System.out.println("\nInvalid selection, please select again.");
			selection = in.nextInt();
		}
		selectedStyle = styleList.get(selection - 1);
		selection = -1;
		
		//Style
		System.out.println("Please select the container the customer ordered:");

		for(int i = 1; i < containerList.size()+1; i++)
		{
			System.out.println("\t"+i+" - " + containerList.get(i - 1).getLabel());
		}
		System.out.print("\nMake a selection:");
		selection = in.nextInt();

		while (selection > containerList.size() || selection < 1)
		{
			System.out.println("\nInvalid selection, please select again.");
			selection = in.nextInt();
		}
		selectedContainer = containerList.get(selection - 1);
		selection = -1;
		
		//Style
		System.out.println("Please select the size the customer ordered:");

		for(int i = 1; i < sizeList.size()+1; i++)
		{
			System.out.println("\t"+i+" - " + sizeList.get(i - 1).getLabel());
		}
		System.out.print("\nMake a selection:");
		selection = in.nextInt();

		while (selection > sizeList.size() || selection < 1)
		{
			System.out.println("\nInvalid selection, please select again.");
			selection = in.nextInt();
		}
		selectedSize = sizeList.get(selection - 1);
		
		return new Ice_Cream(selectedFlavor, selectedStyle, selectedContainer, selectedSize);
	}
	
	public static void main(String args[])
	{
		Ice_Cream stub = new Ice_Cream();
		stub.submenuPrompt();
	}
}
